<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>诗词乐游飞花令</title>
    <script>
        const submitUrl = "{{url_for('player.submit', paper_id=PaperID)}}"
        const finishPaperUrl = "{{url_for('player.finishPaper', paper_id=PaperID)}}"
        const logoutUrl = "{{url_for('player.logout_player')}}"
        const loginWebUrl = "{{url_for('player.login_player_web')}}"
    </script>
    <script src="{{ url_for('static',filename='js/jquery-3.7.1.min.js') }}"></script>
    <script src="{{ url_for('static',filename='js/game.js') }}"></script>
    <script src="{{ url_for('static',filename='js/layui.js') }}"></script>
    <link rel="stylesheet" href="{{ url_for('static',filename='css/layui.css') }}">
    <link rel="icon" href="{{ url_for('static',filename='img/logo.ico') }}">
    <script src="{{ url_for('static',filename='js/music_controller.js') }}"></script>

    <style>
        body {
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
            font-family: 'Microsoft YaHei', sans-serif;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 20px;
            background-color: white;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 8px;
            margin-bottom: 20px;
        }

        .score {
            font-size: 24px;
            font-weight: bold;
            color: #1E9FFF;
        }

        .container {
            display: grid;
            grid-template-columns: repeat({{ PaperJson.width }}, 1fr);
            grid-template-rows: repeat({{ PaperJson.height }}, 1fr);
            width: 80vw;
            height: 80vw;
            margin: 0 auto;
            background-color: white;
            padding: 10px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        .default {
            font-size: {{ 60/PaperJson.width }}vw;
            font-family: 'SimSun', serif;
            display: flex;
            justify-content: center;
            align-items: center;
            border: 1px solid #e0e0e0;
            background-color: #E8F4FF;
            border-radius: 4px;
            transition: all 0.3s ease;
            cursor: pointer;
        }

        .word_back {
            font-size: {{ 60/PaperJson.width }}vw;
            font-family: 'SimSun', serif;
            display: flex;
            justify-content: center;
            align-items: center;
            border: 1px solid #e0e0e0;
            background-color: #FFE7BA;
            border-radius: 4px;
            transition: all 0.3s ease;
        }

        .click_back {
            font-size: {{ 60/PaperJson.width }}vw;
            font-family: 'SimSun', serif;
            display: flex;
            justify-content: center;
            align-items: center;
            border: 1px solid #e0e0e0;
            background-color: #FFB6B9;
            border-radius: 4px;
            transition: all 0.3s ease;
        }

        .input-section {
            max-width: 600px;
            margin: 20px auto;
            padding: 20px;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        .input-group {
            margin-bottom: 15px;
        }

        .input-group label {
            display: block;
            margin-bottom: 5px;
            color: #666;
            font-weight: bold;
        }

        .layui-input {
            border-radius: 4px;
            margin-bottom: 10px;
        }

        .layui-select {
            width: 100%;
            border-radius: 4px;
        }

        #upload {
            width: 100%;
            margin-top: 15px;
        }

        .audio-player {
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 1000;
        }

        /* 悬停效果 */
        .default:hover {
            transform: scale(1.05);
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        /* 按钮动画 */
        .layui-btn {
            transition: all 0.3s ease;
        }

        .layui-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <div class="header">
        <form>
            <button id="logout" class="layui-btn layui-bg-red">退出登录</button>
            <button id="finishPaper" class="layui-btn layui-bg-red">结束游戏</button>
        </form>
        <div class="score">当前分数：{{ PaperJson.score }}</div>
    </div>

    <div class="container">
        {% for i in range(PaperJson.height) %}
            {% for j in range(PaperJson.width) %}
                {% if(PaperJson.data[i][j] ) %}
                    <div class="word_back" id="{{ i }}_{{ j }}">
                        {{ PaperJson.data[i][j] }}
                    </div>
                {% else %}
                    <div class="default" id="{{ i }}_{{ j }}">
                        {{ PaperJson.data[i][j] }}
                    </div>
                {% endif %}
            {% endfor %}
        {% endfor %}
    </div>

    <div class="input-section">
        <div class="input-group">
            <label for="poem">诗词内容</label>
            <input id='poem' class="layui-input" type="text" placeholder="请输入诗词内容">
        </div>

        <div class="input-group">
            <label for="row">首个汉字第几行</label>
            <input id='row' class="layui-input" type="number" placeholder="请输入行数">
        </div>

        <div class="input-group">
            <label for="col">首个汉字第几列</label>
            <input id='col' class="layui-input" type="number" placeholder="请输入列数">
        </div>

        <div class="input-group">
            <label for="direction">方向</label>
            <select name="direction" id="direction" class="layui-input">
                <option value="right">向右 →</option>
                <option value="down">向下 ↓</option>
                <option value="left">向左 ←</option>
                <option value="up">向上 ↑</option>
            </select>
        </div>

        <button id="upload" class="layui-btn layui-bg-blue">提交</button>
    </div>

    <div class="audio-player">
        <audio src="{{ url_for('static',filename='music/鲸鱼音频.MP3') }}" id="background-music" controls="controls" loop="loop" autoplay="autoplay"></audio>
    </div>
</body>
</html>